package com.lyf.baoxian.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.lyf.baoxian.R;
import com.lyf.baoxian.bean.CustomerBaoDan;

import java.util.List;

/**
 * Created by 刘亚飞 on 2016/11/30.
 * 保单管理的adapter
 */

public class BaoDanAdapter extends BaseAdapter {
    private List<CustomerBaoDan> datas;
    private Context context;

    public BaoDanAdapter(Context context) {
        this.context = context;
    }


    public void setDatas(List<CustomerBaoDan> datas){
        this.datas = datas;
        notifyDataSetChanged();
    }
    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int i) {
        return datas.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder;
        if (view == null) {
            view = LayoutInflater.from(context).inflate(R.layout.list_item_toubao,null);
            holder = new ViewHolder();
            holder.tv_date = (TextView) view.findViewById(R.id.tv_date);
            holder.tv_name = (TextView) view.findViewById(R.id.tv_name);
            holder.tv_taocan = (TextView) view.findViewById(R.id.tv_taocan);
            holder.tv_statue = (TextView) view.findViewById(R.id.tv_statue);
            view.setTag(holder);
        }else {
            holder = (ViewHolder) view.getTag();
        }

        CustomerBaoDan customerBaoDan = datas.get(i);
        holder.tv_date.setText(customerBaoDan.getDate()+"");
        holder.tv_name.setText(customerBaoDan.getName()+"");
        holder.tv_statue.setText(customerBaoDan.getStatue()+"");
        holder.tv_taocan.setText(customerBaoDan.getTaoCan()+"");
        return view;
    }

    class ViewHolder{
        TextView tv_date;
        TextView tv_name;
        TextView tv_taocan;
        TextView tv_statue;

    }
}
